<?php
require_once('../../../config.php');
require_once($CFG->libdir . '/accesslib.php');
require_once($CFG->libdir . '/adminlib.php');

//yeu cau login,sau khi login tu dong chuyen sang trang chu
global $USER;
if ($USER->id == null){
    $SESSION->homepage = true;
    require_login($SITE);
}
if($SESSION->homepage){
    $SESSION->homepage = null;
    redirect( $CFG->wwwroot);
} 
//class
require_once($CFG->dirroot . '/local/blackboxsurvey/class/questions.php');
require_once($CFG->dirroot . '/local/blackboxsurvey/class/question_choice.php');
define('AJAX_SCRIPT', true);

//lay question id can xoa
$id = required_param('id', PARAM_TEXT);
/* Xoa question */
$temp = new b_questions();
$success = $temp->delete_question($id);

//xoa question choice
$ques_choice = new b_question_choice();
$ques_choice->delete_choice_by_questionID($id);
//kiem tra xoa thanh cong
if($success){
    echo "true";
}
else{
    echo "false";
}